#include <iostream>
#include <vector>
using namespace std;

int search(vector<int> &a, int target)
{
	int n = a.size();
	int left = 0, right = n - 1;
	while (left < right)
	{
		int mid = left + (right - left) / 2;
		if (a[mid] >= target)
		{
			right = mid;
		}
		else
		{
			left = mid + 1;
		}
	}
	return a[left] == target ? left : -1;
}

int main()
{
	vector<int> a = {1, 3, 5, 7, 7, 9, 10};
	cout << "target在数组中的下标：" << search(a, 7) << endl;
	return 0;
}
